#输出400HZ频率声音
# 计算 1/400/2=0.00125秒
# 将0.00125 填入 
for i in range(100):
    buzzer.value(1)
    time.sleep(0.00125)
    buzzer.value(0)
    time.sleep(0.00125)

# 播放20-2000Hz
from machine import Pin
import time

buzzer = Pin(5, Pin.OUT)   # 创建引脚15为蜂鸣器对象，设置引脚15为输出
hz = 20
ms = 1/hz/2

while True:
    ms = 1/hz/2
    for i in range(100):
        buzzer.value(1)
        time.sleep(ms)
        buzzer.value(0)
        time.sleep(ms)
    hz +=2
    if (hz > 2000)
        break;